<?php
/**
 * Created by PhpStorm.
 * User: lyh
 * Date: 2017/8/12
 * Time: 15:02
 */
namespace App\Http\ViewComposers;
use App\Http\Model\Article;
use App\Repositories\UserRepository;
use Illuminate\View\View;

class ProfileComposer{

    /**
     * 用户仓库实现.
     *
     * @var UserRepository
     */
    protected $users;

    /**
     * 创建一个新的属性composer.
     *
     * @param UserRepository $users
     * @return void
     */
    public function __construct(UserRepository $users)
    {
        // Dependencies automatically resolved by service container...
        $this->users = $users;
    }

    /**
     * 绑定数据到视图.
     *
     * @param View $view
     * @return void
     */
    public function compose(View $view)
    {


        $insititude_nums=$this->users->getNumber();

        //获取当前登录用户的id
        $user=$this->users->getId();


        $article_nums=Article::where('status','0')->count();
        $arr=[
            'insititude_nums'=>$insititude_nums,
            'article_nums'=>$article_nums,
            'super_id'=>$user['id'],
        ];
       $view->with('common_arr',$arr);
    }
}